//
//  UIBarButton+Extension.swift
//  sinaWeiBo
//
//  Created by Xuwei Yang on 16/8/8.
//  Copyright © 2016年 Xuwei Yang. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    //遍历够着函数创建UIBarButtonItem类型的对象
    convenience init(title: String, target: AnyObject?, action: Selector) {
        self.init()
        let button = UIButton()
        //添加点击事件
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        button.setTitle(title, forState: .Normal)
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        button.sizeToFit()
        //  设置自定义视图
        customView = button
    }
    
}
